public class Draw {
    private int height;

    // 构造函数，初始化高度，要求至少超过3行
    public Draw(int height) {
        if (height <= 3) {
            throw new IllegalArgumentException("高度必须超过3行");
        }
        this.height = height;
    }

    // 绘制三角形的方法
    public void drawTriangle() {
        for (int i = 1; i <= height; i++) {
            for (int j = 0; j < height - i; j++) {
                System.out.print(" ");
            }
            for (int k = 0; k < 2 * i - 1; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制矩形的方法
    public void drawRectangle() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < height; j++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    // 绘制正方形的方法
    public void drawSquare() {
        drawRectangle();
    }

    // 绘制平行四边形的方法
    public void drawParallelogram() {
        for (int i = 0; i < height; i++) {
            for (int j = 0; j < i; j++) {
                System.out.print(" ");
            }
            for (int k = 0; k < height; k++) {
                System.out.print("*");
            }
            System.out.println();
        }
    }

    public static void main(String[] args) {
        Draw draw = new Draw(5);
        System.out.println("绘制三角形:");
        draw.drawTriangle();
        System.out.println("绘制矩形:");
        draw.drawRectangle();
        System.out.println("绘制正方形:");
        draw.drawSquare();
        System.out.println("绘制平行四边形:");
        draw.drawParallelogram();
    }
}